﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.DataModel;
using Miris.HumanMilkAnalyser.Service;
using Miris.HumanMilkAnalyser.Service.Shared;
using Miris.HumanMilkAnalyser.WPF.Model;

namespace Miris.HumanMilkAnalyser.WPF.ViewModel.TestItemViewModel
{
    public class TestItemCrudeProteinViewModel : TestItemSingleViewModel
    {
        /// <summary>
        /// Initializes a new instance of the CrudeProteinTestItemViewModel class.
        /// </summary>
        public TestItemCrudeProteinViewModel(IDataService dataService, IList<AnalysisItem> analysisItemList, MilkStage milkStage)
            : base(dataService, analysisItemList, milkStage) { }

        protected override void InitializeParameters()
        {
            base.InitializeParameters();

            TestItemName = AnalysisItemDefinition.CrudeProteinItemName;
            SetAnalysisItem();
        }

        /// <summary>
        /// Set RangeStartValue & RangeEndValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultRangeValue()
        {
            if (CurrentMilkStage == MilkStage.Unmature)
            {
                //RangeStartValue = 1.46;
                //RangeEndValue = 6.8;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinUnmatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinUnmatureMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                //RangeStartValue = 1.27;
                //RangeEndValue = 1.89;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinTransitionalMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinTransitionalMilkRangeEndValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                //RangeStartValue = 0.73;
                //RangeEndValue = 2.0;

                RangeStartValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinMatureMilkRangeStartValue);
                RangeEndValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinMatureMilkRangeEndValue);
            }
        }

        /// <summary>
        /// Set MinValue & MaxValue based on CurrentMilkStage.
        /// </summary>
        protected override void SetTestResultMinMaxValue()
        {
            base.SetTestResultMinMaxValue();

            //MaxValue = CurrentMilkStage == MilkStage.Unmature ? 10 : 5;

            if (CurrentMilkStage == MilkStage.Unmature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinUnmatureMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Transitional)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinTransitionalMilkMaxValue);
            }
            else if (CurrentMilkStage == MilkStage.Mature)
            {
                MaxValue = ConfigFileUtility.GetValue<double>(ConfigurationConstant.CrudeProteinMatureMilkMaxValue);
            }
        }
    }
}
